<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 1.数组去重[1,2,5,6,4,5,6,7,3,8,2,4,6,9]，返回一个新数组

        let arr1 = [1,2,5,6,4,5,6,7,3,8,2,4,6,9,8,7,0,8,10,1,1,1,1,1,1] //初始数组     
        function noRepeat(arr) {
            let arr0 = [] //创建空数组
            let arr1 = arr.sort(function (a, b) {return a - b}) //从小到大重新排序
            maxNumber = arr1[arr1.length - 1] //获取数组内最大值
            for (i = 0; i <= maxNumber; i++) {
                let j = arr1.indexOf(i);
                if (j != -1) {
                    arr0.push(arr1[j])
                }
            }
            return arr0;
        }
        console.log(noRepeat(arr1))

        // arr.forEach(function (item) {
        //     let arr0 = [];
        //     if (arr0.indexOf(arr1[]) != -1) {

        //     }
        // })



        // 2.根据输入的三个数字，求它是这一年的第几天
        function dayNumber(year, mm, dd) {
            let md = [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
            let d = 0;
            if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { //闰
                Feb = 29;
            } else if (year % 4 != 0 || year % 100 == 0) {
                Feb = 28;
            } else {
                console.log(月份错误)
            }
            for (i = 0; i < mm - 1; i++){
                d += md[i];
            }
            if (mm <= 2) {
                day = d + dd;
            } else {
                day = d + dd + Feb;
            }
            return day;
        }
        console.log(dayNumber(2025,7,9))


        //3.开奖按钮，红色球池1-36的数，蓝色球池1-16数，随机6个红球和1个蓝球组合，红球不能重复
        let red = []
        let blue = []
        
        for (i = 1; i <= 36; i++) {
            red.push(i)
        }
        for (i = 1; i <= 16; i++) {
            blue.push(i)
        }
        function number() {
            let number = []
            for (i = 0; i <= 5; i++) {
                randomNum = parseInt(Math.random() * red.length);
                number.push(red[randomNum])
                red.splice(randomNum, 1)
            }
            randomNum = parseInt(Math.random() * blue.length);
            randomBlue = parseInt(Math.random() * 6)
            number.splice(randomBlue, 0, randomNum)
            return number;
        }

        console.log(number())

    </script>
</body>
</html>